package com.boatAnchorAssistant.pojo.valid;

import com.boatAnchorAssistant.pojo.validation.NameValidation;
import javax.validation.Constraint;
import javax.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * @author Joseph.Li
 * @author joseph.li@king-v.com
 * Created in 2022-06-28 15:10
 * <p>
 * 名称格式校验
 */
@Documented
@Constraint(validatedBy = NameValidation.class)
@Target({ FIELD})
@Retention(RUNTIME)
public @interface Name {


    /**
     * 默认正则匹配规则
     * <p>
     *
     * @return
     */
    String pattern() default "^[a-zA-Z0-9_\\u4e00-\\u9fa5]{2,12}$";


    /**
     * 提示
     *
     * @return
     */
    String message() default "名称格式错误";


    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

}
